package com.bootcamp.java;

/**
 * @program: ArrayCode
 * @description: test variable parameters
 * @author: Keyu Li
 * @create: 2021-08-26 20:50
 **/

public class VariableParameters {
    public static void main(String[] args) {
        System.out.println(getMax(1,2,3,4,5,6));
        System.out.println(getMax(1,2,3,4,5));
        System.out.println(getMax(1,2,3,4));
        System.out.println(getMax(1,2,3));
        System.out.println(getMax(1,2));
        System.out.println(getMax(1));
    }

    public static int getMax(int... value) {
        int max = value[0];
        for (int i : value) {
            max = max > i ? max : i;
        }
        return max;
    }
}
